const mongoose = require('mongoose')

const User =require("./user.js")

const rankrSchema = new mongoose.Schema({
    user_id: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "User"
    },
    test_grade:{
        type: Number,
        required: [true, "几年级"] //0~n
    },
    test_project:{
        type: Number,
        required: [true, "科目"]    //语文1 数学2 外语3 政治4 历史5 地理6 物理7 化学8 生物9
    },
    test_type:{
        type: Number,
        required: [true, "考试类型"]  //日常1 周测2 月测3

    },
    test_rank: {
        type: Number,
        maxlength: 3,
        minlength: 0,
        required: [true, "转化后的100制成绩"]    //0~100
    },
    test_rank1: {
        type: Number,
        maxlength: 3,
        minlength: 0,
        required: [true, "填写实际成绩"]    //0~100
    },
    test_rank2: {
        type: Number,
        maxlength: 3,
        minlength: 0,
        required: [true, "填写实际成绩总分"]    //0~100
    },
    test_name: {
        type: String,
        required:true,
    },

    class_ranking: {
        type: Number,
       
    },
    school_ranking: {
        type: Number,

    },
    area_ranking: {
        type: Number,
  
    },
    city_ranking: {
        type: Number,
    
    },
  
    test_note:{ 
        type: String,
    },
   
    push_time: {
        type: String,
        required:true
    }
})

// 创建集合
const Rank = mongoose.model('Rank', rankrSchema);

// 将用户集合做为模块成员进行导出
module.exports = Rank

async function add(){
for(let i=0;i<200;i++){
    let data=await new Rank({ 
        user_id:"5f684ca8fc66cb20b04a7717",
        test_grade:2,
        test_project:1,
        test_rank:98,
        test_name:`这是第${i}次测试`,
        test_ranking1:96,
        test_ranking2:152,
        test_ranking3:963,
        test_ranking4:1000,
        test_ranking5:2000, 
        test_type:0
    
    }).save()
    console.log(data)
}
}

// add()